﻿using System.Collections.Generic;
using System.Linq;

#if API
using HttpEn = HIHS.Net.Http.HttpApiClient;
#else
using System.Net;
#endif


namespace VersionManage.Logic
{
    public class HttpUtility : VersionManage.Logic.Utility
    {

        /// <summary>
        /// 登录服务器
        /// </summary>
        /// 
        public static HttpUtility LoginServerHttpUtility
        {
            get;
            set;
        }

        /// <summary>
        /// 权限与组织架构
        /// </summary>
        public static HttpUtility PermissionServerHttpUtility
        {
            get;
            set;
        }

        /// <summary>
        /// Focus Server Java后端服务
        /// </summary>
        public static HttpUtility FocusServerHttpUtility
        {
            get;
            set;
        }

        /// <summary>
        /// IM服务
        /// </summary>
        public static HttpUtility IMServerHttpUtility
        {
            get;
            set;
        }
        /// <summary>
        /// 配置服务
        /// </summary>
        public static HttpUtility SettingServerHttpUtility
        {
            get;
            set;
        }
        /// <summary>
        /// 创建自定义服务器HttpUtility
        /// </summary>
        /// <param name="baseAddress"></param>
        /// <returns></returns>
        public static HttpUtility CreateUtility(string baseAddress, string[] headers)
        {
            HttpUtility util = new HttpUtility();
            util.BaseAddress = baseAddress;
            util.Headers = headers == null ? null : headers.ToList();
            return util;
        }









        private HttpUtility()
        { }

        public HttpUtility(string baseAddress, List<string> headers)
        {
            if (headers != null)
                 Headers = headers;
            this.BaseAddress = baseAddress;
        }

        public override void RequestCreating(HttpItem item)
        {
            base.RequestCreating(item);
        }

        /*在请求之前修改Request的参数示例
         * 在请求之前修改Request的参数
         
        

        /// <summary>
        /// 方法1,重写父类RequestCreating
        /// 各种参数与开关详见HttpItem类
        /// </summary>
        /// <param name="item"></param>
        public override void RequestCreating(HttpItem item)
        {
            base.RequestCreating(item);
        }

        /// <summary>
        /// 方法2,添加RequestCreating
        /// 各种参数与开关详见HttpItem类
        /// </summary>
        /// <param name="item"></param>
        private HttpUtility()
        {
            base.RequestCreatingEvent += HttpUtility_RequestCreatingEvent;
        }

        void HttpUtility_RequestCreatingEvent(object obj, HttpItem item)
        {
            //查看或修改item
        }
        */

    }

    //public class UserServerUtility : HttpUtility
    //{
    //    public UserServerUtility(string baseAddress, List<string> headers):base(baseAddress,headers)
    //    {
    //    }

    //    public override void RequestCreating(HttpItem item)
    //    {
    //        base.RequestCreating(item);
    //        item.
    //    }
    //}

    public class ServicesAddress
    {
        private static string basepath = "http://121.36.110.208:8088/api/";
        //private static string basepath = basepath + "http://127.0.0.1:6666/api/";
        private static string versionManageAddress = basepath+"versionmanages";

        public static string ServerFilePath { get => basepath+"file/"; }
        //private static string versionManageAddress = "http://localhost:5921/api/versionmanages";
        /// <summary>
        /// 配置服务地址
        /// </summary>
        public static string VersionManageAddress
        {
            get { return versionManageAddress; }
            set { versionManageAddress = value; }
        }
        

    }


   

}
